package chapter2.eg5;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.channels.AsynchronousServerSocketChannel;
import java.util.concurrent.CountDownLatch;
import org.junit.Test;

public class EchoServer {
  @Test
  public void testServer() throws IOException, InterruptedException {
    CountDownLatch latch = new CountDownLatch(1);
    AsynchronousServerSocketChannel server = AsynchronousServerSocketChannel.open();
    server.bind(new InetSocketAddress(8080));
    server.accept(server, new AcceptCompletionHandler());
    latch.await();
  }

}
